// Copyright (c) 2022 Presto Labs Pte. Ltd.
// Author: fengyang

#pragma once

#include <cstdint>
#include <atomic>

namespace coin2::exchange::base::feed::counter {
namespace impl {

class FeedCounter {
 public:
  explicit FeedCounter() {}
  uint64_t ReceiveOneMsg() {
    return ++received_num_;
  }
  uint64_t ProcessOneMsg() {
    return ++processed_num_;
  }
  uint64_t PublishOneMsg() {
    return ++published_num_;
  }
  uint64_t ConsumeOneMsg() {
    return ++consumed_num_;
  }

  uint64_t ReceivedNum() const {
    return received_num_;
  }
  uint64_t ProcessedNum() const {
    return processed_num_;
  }
  uint64_t PublishedNum() const {
    return published_num_;
  }
  uint64_t ConsumedNum() const {
    return consumed_num_;
  }

 private:
  std::atomic<uint64_t> received_num_{0};
  std::atomic<uint64_t> processed_num_{0};
  std::atomic<uint64_t> published_num_{0};
  std::atomic<uint64_t> consumed_num_{0};
};

}  // namespace impl

using impl::FeedCounter;

}  // namespace coin2::exchange::base::feed::counter
